package com.jdrx.sw.sewage.api.web;

import com.jdrx.platform.common.support.gateway.GwConstants;
import com.jdrx.platform.commons.rest.beans.vo.ResponseVO;
import com.jdrx.platform.commons.rest.factory.ResponseFactory2;
import com.jdrx.sw.sewage.beans.dto.MedicineAnalysisAddDTO;
import com.jdrx.sw.sewage.beans.dto.MedicineAnalysisQueryDTO;
import com.jdrx.sw.sewage.beans.vo.MedicineAnalysisVO;
import com.jdrx.sw.sewage.beans.vo.base.PageVO;
import com.jdrx.sw.sewage.service.MedicineAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/api/medicineAnalysis")
@Api(value = "药剂台账")
public class MedicineAnalysisApi {
    @Autowired
    private MedicineAnalysisService medicineAnalysisService;

    @ApiOperation(value = "新增药剂台账")
    @PostMapping(value = "add")
    public ResponseVO<?> add(@RequestHeader(GwConstants.TRANSPARENT_USERID_FEILD) Long uid,
                             @RequestBody @Validated MedicineAnalysisAddDTO dto) {
        medicineAnalysisService.add(dto, uid);
        return ResponseFactory2.ok();
    }

    @ApiOperation(value = "药剂台账分页列表", response = MedicineAnalysisVO.class)
    @PostMapping(value = "pageList")
    public ResponseVO<PageVO<MedicineAnalysisVO>> pageList(@RequestBody @Validated MedicineAnalysisQueryDTO dto) {
        return ResponseFactory2.ok(medicineAnalysisService.pageList(dto));
    }
}